package com.example.stock.entity.eo;


import cn.hutool.core.util.NumberUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.time.LocalDateTime;
import java.util.List;

@TableName("trade")
@Data
public class UnitEo {

    @TableId(type = IdType.AUTO)
    private Integer id;

    @TableField("ru_id")
    private Integer ruId;
    //交易分组
    @TableField("tr_group")
    private Integer trGroup;

    @TableField("tr_plus")
    private Double trPlus;

    //名称
    @TableField("st_name")
    private String stName;

    //代码
    @TableField("st_code")
    private String stCode;

    //现价
    @TableField("tr_price")
    private Double trPrice;

    //成本
    @TableField("st_price")
    private Double stPrice;

    //持仓
    @TableField("st_qty")
    private Double stQty;

    //阶梯
    @TableField("tr_step")
    private Integer trStep;

    //单位
    @TableField("tr_unit")
    private Double trUnit;

    //时间
    @TableField("tr_Date")
    private LocalDateTime trDate;

    @TableField("mark")
    private Integer mark;

    //升-卖 (条件单)
    @TableField(exist = false)
    public UnitEo.UpVo upVo;

    //跌-买 (条件单)
    @TableField(exist = false)
    public UnitEo.DownVo dnVo;

    //规则
    @TableField(exist = false)
    private RuleEo rule;



    //成本
    public Double getStMoney(){
        return NumberUtil.round(stQty*trPrice,6).doubleValue();
    }

    //收益
    public Double getStProfit(){
        return NumberUtil.round(stQty*(trPrice-stPrice),6).doubleValue();
    }

    @Data
    public static class UpVo{
        public Double trPrice;
        public Double trQty;
        public Double upPercent;
        public Double upMoney;
    }

    @Data
    public static class DownVo{
        public Double trPrice;
        public Double trQty;
        public Double dnPercent;
        public Double dnMoney;
    }


}
